#-------------------------------------------------------------------------------
#
#	Name    : ASM
#	Purpose : StrongED mode file for ASM assembler source files
#	Author  :  Fred Graute
#	Licence : Freeware
#	Version : 1.05, 08-02-03
#
#	Assembly may be started with F10.
#
#-------------------------------------------------------------------------------
# 22-09-2002 FG Added instructions supported by newer processors (MRS, MSR etc).
#               Suggested by Christopher Bazley.
# 01-10-2002 FG Commented out PSR specifiers that ARM-ARM declares obsolete.
# 08-09-2003 FG Added clicklist to load header files
#               Suggested by Philip Ludlam
#-------------------------------------------------------------------------------

HelpPath	Assembly,Wimp,OS,MiscSWIs,INetSWIs,Toolbox,OSLib,UnixLib

ID_FirstChar	A-Za-z_$
ID_Middle	A-Za-z_0-9

Search
	Bchar		Alpha   |"_"|"`"
	Bchar2		AlphaNum|"_"|"`"
	_MarkWord	(Bchar {Bchar2} ["%"|"$"]) | ("&" {Hex}+) | {Digit}+
	_MoveWord	(Bchar {Bchar2} ["%"|"$"]) | ("&" {Hex}+) | {Digit}+
	GoLabel		< CW ~Bchar2
	Label		< Bchar {Bchar2}
	Fold_Start	Label
	Fold_End	("MOV" * "PC,") | ("LDM" * "PC")
	Flt_Opt		"al" | "eq" | "ne" | "cc" | "cs" | "mi" | "pl" | "nv" | "vc" | "vs" | "hi" | "ls" | "ge" | "lt" | "gt" | "le" | "hs" | "lo"
	Flt_Rnd		"n" | "p" | "m" | "z"
	Flt_Pre		"s" | "d" | "e" | "p"
#	Flt_Asm		[Flt_Opt] [Flt_Pre] [Flt_Rnd] " "
	Flt_Asm		([Flt_Opt] [Flt_Pre] [Flt_Rnd]) " "
	Get1		[_spct] "INCLUDE" _spct @0 {Bchar2}+ ":" {AlphaNum | "."}+ @9
	Get2		[_spct] "INCLUDE" _spct @0 {AlphaNum}+ "." {AlphaNum | "."}+ @9
End

ClickList
	Get1	LoadOne("<Tmp$Word>")
	Get2	SetTmp(Get2, "Tmp$Word") LoadOne("<Tmp$Path>.^.<Tmp$Word>")
End

SyntaxOptions
	SingleQuote	Yes
	DoubleQuote	Yes
	QuoteChar	\
	QuoteQuote	No
	SplitString	Yes
	HexPrefix	&
End

SyntaxComment
	Type		OneLine
	StartWith	;
End

SyntaxWords Group1 EndOfExpr Flt_Asm nocase
	ABS ACS ASN ATN COS EXP LGN LOG MNF MVF NRM RND SIN SQT TAN URD
	ADF DVF FDV FML FRD MUF POL POW RDF RMF RPW RSF SUF
	FIX FLT RFS RFC WFC WFS
	CMF CNF CMFE CNFE
	LDF STF
End

SyntaxWords Group2 EndAsm nocase
	ADC ADD AND BIC CMN CMP EOR MLA MOV MUL
	MVN ORR RSB RSC SBC SUB SWI TEQ TST
	LDR STR
	ADR
# ARM3 instructions
	SWP
# ARM6 instructions
	MRS MSR
# ARM7M instructions
	UMULL SMULL UMLAL SMLAL
# StrongARM instructions
	LDRH STRH LDRSH STRSH LDRSB STRSB
End

SyntaxWords Group3 EndBL nocase
	B
End

SyntaxWords Group4 EndSTM nocase
	LDM STM
End

SyntaxWords Group5 EndNonID nocase
	R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15
	F0 F1 F2 F3 F4 F5 F6 F7
	LINK
# APCS-R registers
	A1 A2 A3 A4 V1 V2 V3 V4 V5 V6 IP FP SP LR PC
# PSR specifiers
	CPSR CPSR_f CPSR_c CPSR_x CPSR_s
	SPSR SPSR_f SPSR_c SPSR_x SPSR_s
# (FG) While ASM accepts the PSR specifiers below they are obsolete, which
#      is why I've commented them out, you should use the ones above.
#	CPSR_all CPSR_flg CPSR_ctl
#	SPSR_all SPSR_flg SPSR_ctl
End

SyntaxWords Group6 EndNonID nocase
	LSR LSL ASR ASL ROR RRX
End

SyntaxWords Group7 EndNonID nocase
	align
	area
	dcb equb
	dcd equd
	dcfd equfd
	dcfe equfe
	dcfp equfp
	dcfs equfs
	dcq equq
	dcs equs
	dcsz equsz
	dcw equw
	define
	else
	endif
	endm
	endstruc
	entry
	export
	ifdef
	ifndef
	import
	include
	macro
	nop
	pragma
	resb
	structure struct
	undefine undef
End

Functions
	Key	F2
	Menu	List of labels  F2
	Icon	LoF
	Help	Hasm_lof
	Select	ListOfFound (Label,Text,Whole,Line,Case,Sort)

	Adjust	ListOfFound (Label,Text,Whole,Line,Case)

	Key	F10
	Menu	Save & Assemble     F10
	Icon	run
	Help	Hasm_run
	Select	SaveDrag("ASM")

	Key	^F10
	Menu	Save & Make      ^F10
	Icon	brick
	Help	Hasm_mak
	Select	SetTmp() SaveDClick("<tmp$path>.^.Makefile")

	Adjust	SetTmp() SaveDClick("<tmp$path>.^.Build")

	Select	SetTmp() LoadOne("<tmp$path>.^.Makefile")

	Adjust	SetTmp() LoadOne("<tmp$path>.^.Build")

	Key	^G
	Menu	Goto label
	Icon	goto
	Help	Hasm_go
	Select	Push GotoFound(GoLabel,Text,Whole,Line,Case)

	Key	^G 2
	Adjust	Push GotoFound(GoLabel,All,Whole,Line,Case)

	Key	^G
	Select	Pop

	Key	^G 2
	Adjust	Pop
End

Shortcuts
	STM{	STMFD   R13!,{R0-R12,LR}\n\n\i\@\n\n\iLDMFD   R13!,{R0-R12,PC}
	STMS{	STMFD   R13!,{R0-R12,LR}\n\n\i\@\n\n\iLDMFD   R13!,{R0-R12,PC}^
	LDM{	LDMFD   R13!,{R0-R12,PC}
	LDMS{	LDMFD   R13!,{R0-R12,PC}^
	``-	;-------------------------------------------------------------------------------\n
	``=	;===============================================================================\n
End

